<?php
declare (strict_types = 1);

namespace app\admin\validate;


class UserValidate extends BaseValidate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'group_id' => 'require|isPositiveInteger',
        'username' => 'require|isNotEmpty',
        'password' => 'require',
        'name' => 'require|max:10',
        'nickname' => 'require|max:10',
        'contact_phone' => 'require|mobile',
        'status' => 'require|in:0,1|token',
        'code' => 'require|captcha'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'group_id' => '请选择部门',
        'username' => '请输入用户名',
        'password' => '请输入密码',
        'name' => '请输入姓名',
        'nickname' => '请输入昵称',
        'contact_phone' => '请输入正确的手机号',
        'status' => '请选择开启或者禁用',
        'status.token' => '令牌错误',
        'code' => '请输入正确的验证码'
    ];

    protected $scene = [
        'save' => ['group_id','username','password','name','nickname','contact_phone','status'],
        'update'  =>  ['group_id','username','name','nickname','contact_phone','status'],
        'login' => ['username','password','code'],
        'edit' => ['name','nickname','contact_phone']
    ];
}
